In [1]:
import warnings
warnings.filterwarnings('ignore')
In [1]:
%connect_info
In [2]:
a = 4
In [2]:
import sunpy
import sunpy.map
import sunpy.lightcurve
import sunpy.data.test
import glob
%matplotlib inline
import matplotlib as mpl
from matplotlib import colors
mpl.rcParams['figure.figsize'] = (10, 9)
import matplotlib.pyplot as plt
In [3]:
path = sunpy.data.test.rootdir
In [4]:
from sunpy import cm
cm.show_colormaps()
In [5]:
gradient = np.linspace(0, 1, 256)
gradient = np.vstack((gradient, gradient))
cmap_list = (plt.get_cmap('hot'), plt.get_cmap('Greys'), cm.get_cmap('sdoaia171'))
fig, axes = plt.subplots(nrows=len(cmap_list), figsize=(20, 5))
for ax, cmap in zip(axes, cmap_list):
fig.subplots_adjust(top=0.95, bottom=0.01, left=0.2, right=0.99)
ax.imshow(gradient, aspect='auto', cmap=cmap)
In [6]:
aiafull = sunpy.map.Map(sunpy.AIA_171_IMAGE)
# defining some constants to replicate how we currently plot AIA maps
mean = aiafull.mean()
std = aiafull.std()
vmin = max(0, mean - 3 * std)
vmax = min(aiafull.max(), mean + 3 * std)
print("max=%f, min=%f" % (aiafull.min(), aiafull.max()))
print("vmin=%f, vmax=%f" % (vmin, vmax))
In [7]:
aia = aiafull
In [8]:
def plot_cmap_norm_compare(sunpy_map, map_min, map_max):
# defining some constants to replicate how we currently plot AIA maps
mean = sunpy_map.mean()
std = sunpy_map.std()
vmin = max(0, mean - 3 * std)
vmax = min(sunpy_map.max(), mean + 3 * std)
norms = (colors.Normalize(vmin, vmax), colors.Normalize(map_min, map_max),
colors.LogNorm(0.1, map_max), colors.PowerNorm(0.5, map_min, map_max),
colors.PowerNorm(0.4, map_min, map_max), colors.PowerNorm(0.3, map_min, map_max),
colors.Normalize(map_min, map_max), colors.Normalize(map_min, map_max),
colors.Normalize(map_min, map_max))
gammas = (1,1,1,1,1,1,1,0.7, 0.4)
names = ("Current", "Linear all range", "LogNorm", "PowerNorm 0.5", "PowerNorm 0.4", "PowerNorm 0.3",
"Linear Gamma 1", "Linear Gamma 0.7", "Linear Gamma 0.4")
fig = plt.figure(figsize=(20, 20))
for plot_num, name, norm, gamma in zip(range(len(names)), names, norms, gammas):
fig.add_subplot(3, 3, plot_num)
sunpy_map.plot_settings['norm'] = norm
sunpy_map.plot_settings['cmap'].set_gamma(gamma)
sunpy_map.plot_settings['title'] = name
sunpy_map.plot()
plt.colorbar()
In [9]:
ax = plt.hist(aiafull.data, log=True)
plt.show()
print("max=%f, min=%f" % (aiafull.min(), aiafull.max()))
In [10]:
plot_cmap_norm_compare(aiafull, aiafull.min(), aiafull.max())
In [11]:
smap = aiafull.submap([0,1000], [0,1000])
In [12]:
ax = plt.hist(smap.data, log=True)
plt.show()
print("max=%f, min=%f" % (smap.min(), smap.max()))
In [13]:
plot_cmap_norm_compare(smap, smap.min(), smap.max())
In [14]:
smap = aiafull.submap([0,600], [0,600])
In [15]:
ax = plt.hist(smap.data, log=True)
plt.show()
In [16]:
plot_cmap_norm_compare(smap, smap.min(), smap.max())
Best solution looks like Linear with Gamma = 0.4
One disadvantage though is that there is visible banding in dark areas (see next)
In [17]:
smap = aiafull.submap([0,1000], [0,1000])
smap.plot_settings['norm'] = colors.Normalize(smap.min(), smap.max())
smap.plot_settings['cmap'].set_gamma(0.4)
smap.plot()
plt.colorbar()
Out[17]:
In [18]:
file = '/Users/schriste/Desktop/sunpy_test_img/aia.lev1.171A_2013-09-21T16_00_11.34Z.image_lev1.fits'
aiafull = sunpy.map.Map(file)
smap = aiafull.submap([-300,600], [-100,600])
In [19]:
ax = plt.hist(smap.data, log=True)
plt.show()
print("max=%f, min=%f" % (smap.min(), smap.max()))
In [20]:
plot_cmap_norm_compare(smap, smap.min(), smap.max())
nothing to see here just reimplementing how we configured the plot before my changes
In [21]:
aia = sunpy.map.Map(sunpy.AIA_171_IMAGE)
#aia.plot_settings['norm'] = colors.LogNorm(1, aia.max())
mean = aia.mean()
std = aia.std()
vmin = max(0, mean - 3 * std)
vmax = min(aia.max(), mean + 3 * std)
aia.plot_settings['norm'] = colors.Normalize(vmin, vmax)
aia.peek(draw_limb=True)
In [22]:
aia = sunpy.map.Map(sunpy.AIA_171_IMAGE, sunpy.AIA_171_IMAGE, composite=True)
aia.set_levels(1, range(0, 50, 5), percent=True)
aia.set_colors(1, 'Reds_r')
aia.peek(draw_limb=True)
In [23]:
eit = sunpy.map.Map(sunpy.EIT_195_IMAGE)
eit.peek()
In [24]:
hsi = sunpy.map.Map(sunpy.RHESSI_IMAGE)
hsi.peek()
In [25]:
fitspath = glob.glob(os.path.join(path, "HinodeXRT.fits"))
xrt = sunpy.map.Map(fitspath)
xrt.peek()
In [26]:
fitspath = glob.glob(os.path.join(path, "HinodeSOT.fits"))
sot = sunpy.map.Map(fitspath)
sot.peek()
In [27]:
fitspath = glob.glob(os.path.join(path, "mdi_fd_M_96m_01d.5874.0005_s.fits"))
mdi = sunpy.map.Map(fitspath)
mdi.peek()
In [28]:
fitspath = glob.glob(os.path.join(path, "lasco_c2_25299383_s.fts"))
lasco = sunpy.map.Map(fitspath)
lasco.peek()
In [29]:
fitspath = glob.glob(os.path.join(path, "iris_l2_20130801_074720_4040000014_SJI_1400_t000.fits"))
lasco = sunpy.map.Map(fitspath)
lasco.peek()
In [ ]:
fitspath = glob.glob(os.path.join(path, "cor1_20090615_000500_s4c1A.fts"))
lasco = sunpy.map.Map(fitspath)
lasco.peek()
In [30]:
fitspath = glob.glob(os.path.join(path, "aia_171_level1.fits"))
lasco = sunpy.map.Map(fitspath)
lasco.peek()
In [31]:
fitspath = glob.glob(os.path.join(path, "euvi_20090615_000900_n4euA_s.fts"))
lasco = sunpy.map.Map(fitspath)
lasco.peek()
In [15]:
import sunpy.map
import matplotlib.pyplot as plt
import glob
%matplotlib inline
import matplotlib as mpl
from matplotlib import colors
mpl.rcParams['figure.figsize'] = (10, 9)
path = '/Users/schriste/Desktop/sunpy_test_img/'
fits_files = glob.glob(os.path.join(path, "*"))
print(len(fits_files))
In [92]:
i = 22
m = sunpy.map.Map(fits_files[i])
m.plot_settings['norm'] = colors.Normalize(np.nanmin(m.data), np.nanmax(m.data))
m.plot_settings['cmap'] = plt.get_cmap('Greys')
print(fits_files[i])
print("max=%f, min=%f" % (m.min(), m.max()))
m.peek()
In [104]:
m.meta
Out[104]:
In [86]:
plt.imshow(m.data)
Out[86]:
In [80]:
m.wavelength
Out[80]:
In [99]:
m.detector
Out[99]:
In [98]:
m.meta['camera']
Out[98]:
In [9]:
fig = plt.figure(figsize=(20, 20))
for plot_num, fits_file in zip(range(len(fits_files)), fits_files):
fig.add_subplot(5, 5, plot_num)
m = sunpy.map.Map(fits_file)
m.plot()
In [32]:
from sunpy import lightcurve
from sunpy.time import TimeRange
tr = TimeRange('2011-06-07 06:00', '2011-06-07 08:00')
In [33]:
goes = lightcurve.GOESLightCurve.create(tr)
goes.peek()
In [34]:
noaa = lightcurve.NOAAIndicesLightCurve.create()
noaa.peek()
In [35]:
noaa = lightcurve.NOAAPredictIndicesLightCurve.create()
noaa.peek()
In [36]:
hsi = lightcurve.RHESSISummaryLightCurve.create(tr)
hsi.peek()
In [37]:
eve = lightcurve.EVELightCurve.create(tr)
eve.peek()
In [38]:
import datetime
base = datetime.datetime.today()
dates = [base - datetime.timedelta(seconds=x) for x in range(0, 1 * 60 * 60)]
z = [((d.minute % 5) == 0) for d in dates]
light_curve = lightcurve.LogicalLightCurve.create({"param1": z}, index=dates)
light_curve.peek()
In [39]:
lyra = lightcurve.LYRALightCurve.create()
lyra.peek()
In [40]:
norh = lightcurve.NoRHLightCurve.create('2011/08/10')
norh.peek()
In [ ]:
In [ ]: